﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Uniforax.Camp.TestData.Common;
using Uniforax.Camp.TestData.SmallStake;
using Uniforax.Core.Common;
using Uniforax.Core.Skills;

namespace Uniforax.Camp.TestData.TheTech
{
    public class UnlockUpgradeArmorSkill : BaseSkill
    {
        // 解锁升级，并且对现在的存在的老单位进行主动升级。
        public override void Effect(ActionContext context, SkillContext skillContext)
        {
            var world = context.GameWorld;

            {   // 解锁该权限。
                var unlockUpgradeArmorAction = new UnlockUpgradeArmorAction();
                context.History.Add(unlockUpgradeArmorAction);
                unlockUpgradeArmorAction.Execute(context);
            }

            {   // 进行指定对象的升级。
                var gameObjectQuery = world.QueryDescendants()
                    .Where(i => i.ArmorManager is TestDataArmorManager);
                foreach (var gameObject in gameObjectQuery)
                {
                    var upgradeArmorAction = new UpgradeTestDataArmorAction(gameObject);
                    context.History.Add(upgradeArmorAction);
                    upgradeArmorAction.Execute(context);
                }
            }


            // UnlockPowerUpAction
        }
    }
}
